package com.niit.session9;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateTimeDemo {
	public static void main(String[] args) {
//		获取当前的年月日时分秒毫秒
		LocalDateTime now = LocalDateTime.now();
		System.out.println(now);
//		获取当前的日期
		LocalDate now2 = LocalDate.now();
		System.out.println(now2);
//		根据数字来初始化一个时间
		LocalDateTime of = LocalDateTime.of(2023,3,10,10,02,02);
		System.out.println(of);
//		获取年份
		System.out.println(now.getYear());
//		日期计算
		System.out.println(now.plusYears(-1));
//		日期格式化
		DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("2023-03-10 周五 09:43:19");
		System.out.println(ofPattern.format(now));
		
	}
}
